package com.zhentao.product.controller;


import com.zhentao.nlz.project.product.TUserInfo;
import com.zhentao.nlz.project.product.vo.UserVo;
import com.zhentao.product.service.TUserInfoService;
import com.zhentao.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("tUserInfo")
public class TUserInfoController {
    @Autowired
    private TUserInfoService tUserInfoService;
    //查询用户
    @RequestMapping("getUserInfo")
    public Result getUserInfo(UserVo userInfoVo){
        List<TUserInfo> list = tUserInfoService.getUserInfo(userInfoVo);
        System.err.println("11111111111111111111111");
        return Result.success(list);
    }
    //添加用户
    @PostMapping("saveUserInfo")
    public Result saveUserInfo(TUserInfo tUserInfo){
        tUserInfo.setCreateTime(new Date());
        boolean b = tUserInfoService.save(tUserInfo);
        return Result.success(b);
    }
    //删除用户
    @PostMapping("removeUserInfo")
    public Result removeUserInfo(Integer id){
        boolean b = tUserInfoService.removeById(id);
        return Result.success(b);
    }
    //修改用户信息
    @PostMapping("updateUserInfo")
    public Result updateUserInfo(TUserInfo tUserInfo){
        boolean b = tUserInfoService.updateById(tUserInfo);
        return Result.success(b);
    }
}
